﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace TSComm.Utilities.Sys
{
    public static class TypeHelper
    {
        public static DbType GetDBType(string StrType)
        {
            DbType dbType = DbType.Object; // 默认是object
            switch (StrType)
            {
                case "int":
                    dbType = DbType.Int32;
                    break;
                case "string":
                    dbType = DbType.String;
                    break;
                case "binary":
                    dbType = DbType.Binary;
                    break;
                case "boolean":
                case "bool":
                    dbType=DbType.Boolean;
                    break;
                case "byte":
                    dbType=DbType.Byte;
                    break;
                case "datetime":
                    dbType = DbType.DateTime;
                    break;
                case "decimal":
                    dbType = DbType.Decimal;
                    break;
                case "dboule":
                    dbType = DbType.Double;
                    break;
                case "guid":
                    dbType = DbType.Guid;
                    break;
                case "xml":
                    dbType = DbType.Xml;
                    break;
            }  

            return dbType;
        }
    }
}
